python中的isalnum、isalpha、istitle、isspace、islower、isupper、isdigit

您所在的位置:网站首页 python isupper() python中的isalnum、isalpha、istitle、isspace、islower、isupper、isdigit

python中的isalnum、isalpha、istitle、isspace、islower、isupper、isdigit

#python中的isalnum、isalpha、istitle、isspace、islower、isupper、isdigit| 来源: 网络整理| 查看: 265

isalnum()判断是否包含字母或者数字

isalpha()判断是否都是字母

istitle()判断每个单词首字母是否是大写

isspace()判断是否是空格

islower()判断字母是否全都是小写

isupper()判断字母是否都是大写

isdigit()判断是否全都是数字

举个例子:

复制代码 1 a = "hello8" 2 b = "world" 3 c = "123456" 4 d = "hello world" 5 e = " " 6 f = "Hello World" 7 g = "YES" 8 a1 = a.isalnum() 9 b1 = b.isalpha() 10 c1 = c.isdigit() 11 d1 = d.islower() 12 e1 = e.isspace() 13 f1 = f.istitle() 14 g1 = g.isupper() 15 print(a1) 16 print(b1) 17 print(c1) 18 print(d1) 19 print(e1) 20 print(f1) 21 print(g1) 复制代码

输出结果:

复制代码 True True True True True True True 复制代码

使用方法如代码书写



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3